const mongoose = require('mongoose')

// 创建文章集合规则
const cartSchema = new mongoose.Schema({
    // 商品id
    goods: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Goods',
      required: [true, '请传递商品id']
    },
    // 用户id
    business: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'User',
      required: [true, '请传递商家id']
    },
    // 用户id
    user: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'User',
      required: [true, '请传递用户id']
    }
})

// 根据规则创建集合
const Cart = mongoose.model('Cart', cartSchema)

// 将集合规则作为模块成员进行导出
module.exports = {
  Cart
}